<template>
  <div class="person">
    <h2>
      求和：{{ sum }}
    </h2>
    <button @click="sum1">修改名字</button>
  </div>
</template>

<script lang="ts" setup name="Person">
import {ref, reactive,watch, computed, toValue} from 'vue'

let sum = ref(1)
//修改全量名称为ref类型数据
function sum1() {
 sum.value += 1;
}

stop = watch(sum,(newVal,oldVal) => {
  console.log('sum =' + sum.value);
  console.log('new=' +newVal);
  console.log('old='+oldVal);

  if (oldVal == 10) {
    stop()
  }
})

console.log(stop);



</script>